按渠道计算 PV 和 UV

按渠道计算 PV 和 UV:

------------------按指定channel_id按月求PV、UV------------
drop table if exists tmp_pvuv;
create table tmp_pvuv
as
select
    t1.channel_id,                              --渠道编号
    t2.year_month,                              --年份月份
    count(distinct t2.visitor_trace) as UV,     --UV     
    sum(t2.pv) as PV                            --PV
from tmp_wangbo3_092502_channelid t1
join
    (select
        from_unixtime(unix_timestamp(dt,'yyyyMMdd'),'yyyy-MM') as year_month,
        pvalue,
        visitor_trace,
        pv
    from dw.kn2_traf_web_log_total  --流量表
    where dt>='20160101' and dt<='20170630'  --2016年1月1日至2017年6月30日
    ) t2 on t1.channel_id=t2.pvalue
group by t1.channel_id,t2.year_month  --按channel_id分组
;

 

转载于:https://www.cnblogs.com/shujuxiong/p/9289727.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值